<?php
 	function db_select_all($table)
	{
		global $wpdb;
		$table = $wpdb->prefix.$table;
		$query	= "SELECT * FROM $table";
		$result	= $wpdb->get_results($query, OBJECT);
		if($result)
			return $result;
		else 
			return false;	
	} 				
?>
<style>
.box-search-tour
{
	margin-top:0;
}
</style>
<div class="box-search-tour">
                	<span class="title">Search Tour</span>
                  <form action="<?php bloginfo('url');?>" method="get">
           	  		<p class="row-1">
           	  				<input type="hidden" name="s" id="s" value="search-tours"/>
           	  				<?php
           	  				if($st=="vietnam")
           	  				{
           	  				?>
           	  				<input checked="checked" type="radio" id="vnst" name="st" value="vietnam"/>
           	  				<?php 	
           	  				} 
           	  				else 
           	  				{
           	  				?>
           	  				<input type="radio" id="vnst" name="st" value="vietnam"/>
           	  				<?php 	
           	  				}
           	  				?>                        	
                            <label id="select_vnst">Vietnam Travel</label>
                            <?php
                            if($st=="international")
                            {
                            ?>
                            <input checked="checked" type="radio" id="interst" name="st" value="international"/>
                            <?php 	
                            } 
                            else 
                            {
                            ?>
                            <input type="radio" id="interst" name="st" value="international"/>
                            <?php 	
                            }
                            ?>                            
                            <label id="select_interst">International Travel</label>                            
                    </p>
                    <p class="row">
                    		<?php
                    		$des_from = db_select_all("destination_from");                    		 
                    		?>
                        	<label class="label-1">Destination From :</label>                        	
                            <select name="destination_from" id="select_destination_from">
                            	<option value="">-- ALL --</option>
                            	<?php
                            	foreach ($des_from as $value) 
                            	{
                            		if($destination_from==$value->destinationFrom)
                            		{
	                            	?>
	                            	<option selected="selected" value="<?php echo $value->destinationFrom;?>"><?php echo $value->destinationFrom;?></option>
	                            	<?php 
                            		}
                            		else 
                            		{
                            		?>
	                            	<option value="<?php echo $value->destinationFrom;?>"><?php echo $value->destinationFrom;?></option>
	                            	<?php	
                            		}
                            	} 
                            	?>                                                                
                            </select>
                            <label class="label-2">To :</label>
                            <?php
                    		$des_to = db_select_all("destination_to");                    		 
                    		?>
                            <select name="destination_to" id="select_destination_to">
                            	<option value="">-- ALL --</option>
                            	<?php
                            	foreach ($des_to as $value) 
                            	{
                            		if($destination_to==$value->destinationTo)
                            		{
		                            	?>
		                            	<option selected="selected" value="<?php echo $value->destinationTo;?>"><?php echo $value->destinationTo;?></option>
		                            	<?php 
                            		}
                            		else 
                            		{
                            		?>
	                            		<option value="<?php echo $value->destinationTo;?>"><?php echo $value->destinationTo;?></option>
	                            	<?php	
                            		}
                            	} 
                            	?>
                                                                
                            </select>
                      </p>
                      <p class="row">
                      		<?php
                      		
                      		global $wpdb;
							$table = $wpdb->prefix.'postmeta';
							$lenght = $wpdb->prefix.'lenght_of_stay';
							$query	= "SELECT meta_key,meta_value FROM $table WHERE meta_key='".$lenght."'";
							$result	= $wpdb->get_results($query, OBJECT);
							
                      		?>
                        	<label class="label-1">Length of stay 	  :</label>
                            <select name="length_of_stay" id="select_length_of_stay">
                            	<option value="">-- Select --</option>
                            	<?php
                            	if($result)
                            	{
	                            	foreach ($result as $value) 
	                            	{
	                            		if($length_of_stay==$value->meta_value)
	                            		{
	                            		?>
		                            	<option selected="selected" value="<?php echo $value->meta_value;?>"><?php echo $value->meta_value;?></option>
		                            	<?php	
	                            		}
	                            		else 
	                            		{
		                            	?>
		                            	<option value="<?php echo $value->meta_value;?>"><?php echo $value->meta_value;?></option>
		                            	<?php 	
	                            		}
	                            	}
                            	} 
	                            	?>                                                                
	                            
                            </select>
                            <input id="submit_go_search" type="submit" value="" />
                      </p>
                    </form>
                </div>